const { formatTime, calPageHeight } = require("../../utils/util");

// pages/sort/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageHeight: 0,
    tabs: [
      { id: 1, text: '菜单1' },
      { id: 2, text: '菜单2' },
      { id: 3, text: '菜单3' },
      { id: 4, text: '菜单4' },
      { id: 5, text: '菜单5' },
      { id: 6, text: '菜单6' },
      { id: 2, text: '菜单2' },
      { id: 3, text: '菜单3' },
      { id: 4, text: '菜单4' },
      { id: 5, text: '菜单5' },
      { id: 6, text: '菜单6' },
      { id: 2, text: '菜单2' },
      { id: 3, text: '菜单3' },
      { id: 4, text: '菜单4' },
      { id: 5, text: '菜单5' },
      { id: 6, text: '菜单6' },
      { id: 2, text: '菜单2' },
      { id: 3, text: '菜单3' },
      { id: 4, text: '菜单4' },
      { id: 5, text: '菜单5' },
      { id: 6, text: '菜单末' }
    ],
    contentItems: [
      { id: 1, title: '内容1', image: 'https://t14.baidu.com/it/u=2337417995,3682422048&fm=224&app=112&size=h200&n=0&f=JPEG&fmt=auto?sec=1733245200&t=195a24f901f0a8fbc4f2f946164fa046'},
      { id: 2, title: '内容2', image: 'https://t14.baidu.com/it/u=2337417995,3682422048&fm=224&app=112&size=h200&n=0&f=JPEG&fmt=auto?sec=1733245200&t=195a24f901f0a8fbc4f2f946164fa046' },
      { id: 3, title: '内容3', image: 'https://t14.baidu.com/it/u=2337417995,3682422048&fm=224&app=112&size=h200&n=0&f=JPEG&fmt=auto?sec=1733245200&t=195a24f901f0a8fbc4f2f946164fa046' },
      { id: 4, title: '内容2', image: 'https://t14.baidu.com/it/u=2337417995,3682422048&fm=224&app=112&size=h200&n=0&f=JPEG&fmt=auto?sec=1733245200&t=195a24f901f0a8fbc4f2f946164fa046' },
      { id: 5, title: '内容3', image: 'https://t14.baidu.com/it/u=2337417995,3682422048&fm=224&app=112&size=h200&n=0&f=JPEG&fmt=auto?sec=1733245200&t=195a24f901f0a8fbc4f2f946164fa046' },
      { id: 6, title: '内容2', image: 'https://t14.baidu.com/it/u=2337417995,3682422048&fm=224&app=112&size=h200&n=0&f=JPEG&fmt=auto?sec=1733245200&t=195a24f901f0a8fbc4f2f946164fa046' },
      { id: 7, title: '内容3', image: 'https://t14.baidu.com/it/u=2337417995,3682422048&fm=224&app=112&size=h200&n=0&f=JPEG&fmt=auto?sec=1733245200&t=195a24f901f0a8fbc4f2f946164fa046' }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    console.log('tabPagePaddingBottom++='+getApp().globalData.tabPagePaddingBottom);
    this.setData({
      paddingBottom: getApp().globalData.tabPagePaddingBottom
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getTabBar().init();
  },

  onMenuItemClick(e) {
    const id = e.currentTarget.dataset.id;
    // 根据点击的菜单项 ID 更新右侧内容
    this.setData({
      contentItems: this.getContentByMenuId(id)
    });
  },

  handleChange(e) {
    const index = e.detail.index;
    this.setData({
      currentIndex: index
    });
  },

  getContentByMenuId(menuId) {
    // 这里可以根据实际需求从后端获取数据或本地模拟数据
    return [
      { id: 1, title: `内容${menuId}-1`, image: 'https://t14.baidu.com/it/u=2337417995,3682422048&fm=224&app=112&size=h200&n=0&f=JPEG&fmt=auto?sec=1733245200&t=195a24f901f0a8fbc4f2f946164fa046' },
      { id: 2, title: `内容${menuId}-2`, image: 'https://t14.baidu.com/it/u=2337417995,3682422048&fm=224&app=112&size=h200&n=0&f=JPEG&fmt=auto?sec=1733245200&t=195a24f901f0a8fbc4f2f946164fa046' },
      { id: 3, title: `内容${menuId}-3`, image: 'https://t14.baidu.com/it/u=2337417995,3682422048&fm=224&app=112&size=h200&n=0&f=JPEG&fmt=auto?sec=1733245200&t=195a24f901f0a8fbc4f2f946164fa046' }
    ];
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})